<template>
  <div style="padding: 10px">
    <el-upload
        style="display: inline-block"
        :action="$baseUrl+'/file/upload'"
        :show-file-list="false"
        :accept="'xlsx'"
        :on-success="handleFileUploadSuccess"
    >
      <el-button type="primary" class="ml-5"
      >上传文件<i class="el-icon-top"></i
      ></el-button>
    </el-upload>
    <el-card>
      <div v-for="item in videos" :key="item.id"
           style="margin: 10px 0; padding: 10px 0; color: #666; border-bottom: 1px solid #ccc">
        <span style="font-size: 18px; cursor: pointer" class="item" @click="detail(item.id)">{{ item.name }}</span>
        <span style="float: right; font-size: 12px; margin-top: 5px">文件大小: {{ item.size }}kb</span>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "Video",
  data() {
    return {
      videos: []
    }
  },
  created() {
    this.request("/echarts/front/all").then(res => {
      console.log(res.data)
        this.videos = res.data.filter(v => v.type === 'mp4' && v.enable == true)
      console.log('this.videos', this.videos)
    })
  },
  methods: {
    //上传文件
    handleFileUploadSuccess(res) {
      console.log(res);
      this.$message.success("上传成功")
      this.load();
    },
    detail(id) {
      console.log('id',id)
      this.$router.push({
        path: "/front/videoDetail",
        query: {id: id}
      })
    }
  }
}
</script>

<style scoped>
.item:hover {
  color: #3a8ee6;
}
</style>